﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace Vehicle.Web.Pages
{
    public partial class Left : Component.PageBase
    {
        /// <summary>
        /// Copyright (C) M-Tear团队
        /// 文 件 名：Left.aspx.cs
        /// 版    本：v1.00.0000
        /// 创建标识：2009-09-10  Created by 孙成杰 V1.00.0000
        /// 功能说明：页面左边功能菜单列表
        /// 注意事项：无
        /// 
        /// 更新记录：
        /// 
        /// </summary>
        #region---基本实例化---
        BLL.Permissions b_Permissions = new BLL.Permissions();//实例化权限逻辑变量
        int r_id;//定义角色ID
        #endregion

        #region---基本操作---
        /// <summary>
        /// 页面加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //查询角色ID
                r_id = Common.TextHelper.StringToInt(b_Permissions.GetModel(new Vehicle.Model.ComponentsInfo("Admin", "A_ID", session_ID.ToString(), "A_ID")).Rows[0]["R_ID"].ToString());
                RepeaterParentBind();//绑定功能菜单
               
            }
        }
        /// <summary>
        /// 根据权限绑定Repeater功能菜单
        /// </summary>
        public void RepeaterParentBind()
        {
            this.Rept.DataSource = b_Permissions.GetLeftList(new Model.ComponentsInfo(r_id, 1, "1", "1"));//通告角色绑定出相应的功能
            this.Rept.DataBind();
        }
        /// <summary>
        /// 根据大模块绑定出小功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Rept_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater rept = (Repeater)e.Item.FindControl("Rept_Son");//查找子模块控件Repeater
                rept.DataSource = b_Permissions.GetModel(new Vehicle.Model.ComponentsInfo("Permissions", "P_Parent", ((DataRowView)e.Item.DataItem).Row["P_ID"].ToString(), "P_ID"));  //根据父节点绑定出相应的子功能模块
                rept.DataBind();//绑定子模块
            }
        }
        #endregion
    }
}
